//
// C++ Interface: timers
//
// Description: Timers dump.
//
//
// Author: Andrey Sharoyko <vanyamboe@gmail.com>, (C) 2011
//
// Copyright: See COPYING file that comes with this distribution
//
//
#if !defined(__TIMERS_H_INCLUDED__)
#define __TIMERS_H_INCLUDED__

#include "dumpmon.h"

#define DUMP_TIMER_8BIT    0
#define DUMP_TIMER_16BIT   1

#if defined(DUMP_ARDUINO)

#   define DUMP_TIMERS_COUNT 3
#   define DUMP_TMCOMP_COUNT 2
#   define DUMP_TIMERS_BIT  (DUMP_TIMER_8BIT | (DUMP_TIMER_16BIT << 1) | (DUMP_TIMER_8BIT << 2))

#elif defined(DUMP_MEGA)

#   define DUMP_TIMERS_COUNT 6
#   define DUMP_TMCOMP_COUNT 3
#   define DUMP_TIMERS_BIT  (DUMP_TIMER_8BIT | (DUMP_TIMER_16BIT << 1) | (DUMP_TIMER_8BIT << 2) \
			 | (DUMP_TIMER_16BIT << 3) | (DUMP_TIMER_16BIT << 4) | (DUMP_TIMER_16BIT << 5))

#else
#   error "TODO: Add board type support here."
#endif

#define DUMP_IS_16BIT_TIMER(tn) ((1 << tn) & DUMP_TIMERS_BIT)

typedef struct {
  unsigned char  timer;
  unsigned char  wgm;
  unsigned char  clksrc;
  unsigned char  clkedge;
  unsigned int   presc;
  unsigned char  mode;
  unsigned char  bits;
  unsigned char  top;
  unsigned char  updocr;
  unsigned char  tovint;
  unsigned char  com[DUMP_TMCOMP_COUNT];
  unsigned char  com0[DUMP_TMCOMP_COUNT];
  unsigned char  com1[DUMP_TMCOMP_COUNT];
  unsigned char  com2[DUMP_TMCOMP_COUNT];
  unsigned char  com3[DUMP_TMCOMP_COUNT];
  unsigned char  com4[DUMP_TMCOMP_COUNT];
  unsigned char  com5[DUMP_TMCOMP_COUNT];
  unsigned char  irqen[4];
  unsigned char  timsk;
} timerdesc_t;

void dumpTimer(unsigned char tn);

#endif // __TIMERS_H_INCLUDED__


